//Servidor de eco UDP
import java.net.*;

public class ServidorUDP {

    public static void main(String [] args) {
    	int porto = 5000;
    	
    	try {
			DatagramSocket socket = new DatagramSocket(porto);
			while(true) {
				byte[] buf = new byte[200];
				DatagramPacket paquete = new DatagramPacket(buf,200);
				socket.receive(paquete);
				
				socket.send(new DatagramPacket(buf,200,paquete.getSocketAddress()));
				System.out.println("Mensaxe enviada... " + new String(buf));
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

}
